<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/static/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/layuiadmin/style/admin.css" media="all">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <fieldset class="layui-elem-field">
                <legend>基本设置</legend>
                <div class="layui-field-box">
                    <div class="layui-card">
                        <div class="layui-card-body" pad15>
                            <div class="layui-tab">
                                <ul class="layui-tab-title">
                                    <li class="layui-this">基本设置</li>
                                    <li>推广设置</li>
                                    <li>金额设置</li>
                                </ul>
                                <div class="layui-tab-content">
                                    <div class="layui-tab-item layui-show">
                                        <div class="layui-form" wid100 lay-filter="">
                                            <div class="layui-form-item">
                                                <label class="layui-form-label">网站名称</label>

                                                <div class="layui-input-inline" style="width: 300px;">
                                                    <input type="text" name="title" lay-verify="required"
                                                           value="{$site.title}" class="layui-input">
                                                </div>
                                            </div>
                                            <!--<div class="layui-form-item">-->
                                            <!--<label class="layui-form-label">小程序logo</label>-->
                                            <!--<div class="layui-upload" style="width: 320px;">-->
                                            <!--<button type="button" class="layui-btn" id="test">上传图片</button>-->
                                            <!--<div style="float: right;line-height: 36px;">推荐: 90 x 20</div>-->
                                            <!--<div class="layui-upload-list">-->
                                            <!--<img class="layui-upload-img" id="demo" src="/uploads/{$site.logo}" style="margin-left: 130px;width: 180px;height: 40px;">-->
                                            <!--<input type="hidden" name="logo" value="{$site.logo}">-->
                                            <!--</div>-->
                                            <!--</div>-->
                                            <!--</div>-->
                                            <div class="layui-form-item">
                                                <label class="layui-form-label">首页公告</label>

                                                <div class="layui-input-inline" style="width: 200px;">
                                                    <input type="text" name="gong" lay-verify="required"
                                                           value="{$site.gong}" placeholder="首页公告" class="layui-input">
                                                </div>
                                            </div>
                                            <div class="layui-form-item">
                                                <label class="layui-form-label">首页广告</label>

                                                <div class="layui-upload" style="width: 335px;">
                                                    <button type="button" class="layui-btn" id="test2">上传图片</button>
                                                    <!--<div style="float: right;line-height: 36px;">推荐: 375 x 240</div>-->
                                                    <div class="layui-upload-list">
                                                        <img class="layui-upload-img" id="demo2"
                                                             src="/uploads/{$site.ad}"
                                                             style="margin-left: 130px;width: 150px;height: 150px;">
                                                        <input type="hidden" name="ad" value="{$site.ad}">
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="layui-form-item">
                                                <label class="layui-form-label">客服电话</label>
                                                <div class="layui-input-inline" style="width: 200px;">
                                                    <input type="text" name="tel" lay-verify="required"
                                                           value="{$site.tel}" placeholder="客服电话" class="layui-input">
                                                </div>
                                            </div>
                                            <div class="layui-form-item">
                                                <label class="layui-form-label">充值页面</label>
                                                <div class="layui-input-inline">
                                                    <input type="checkbox" name="open" value="1" lay-skin="switch" lay-text="开启|关闭" {if condition="$site.open eq 1"}checked{/if}>
                                                </div>
                                            </div>
                                            <div class="layui-form-item">
                                                <div class="layui-input-block">
                                                    <button class="layui-btn" lay-submit lay-filter="set_website">确认保存</button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-tab-item">
                                        <div class="layui-form" wid100 lay-filter="">
                                            <div class="layui-form-item">
                                                <label class="layui-form-label">分销开关</label>
                                                <div class="layui-input-inline">
                                                    <input type="checkbox" name="retail_open" value="1" lay-skin="switch" lay-text="开启|关闭" {if condition="$site.retail_open eq 1"}checked{/if}>
                                                </div>
                                            </div>
                                            <div class="layui-form-item">
                                                <label class="layui-form-label">分销类型</label>
                                                <div class="layui-input-block">
                                                    <input type="radio" name="retail_type" value="1" title="指定分销" {if condition="$site.retail_type eq 1"}checked{/if}>
                                                    <input type="radio" name="retail_type" value="2" title="全民分销" {if condition="$site.retail_type eq 2"}checked{/if}>
                                                </div>
                                            </div>
                                            <div class="layui-form-item">
                                                <label class="layui-form-label">推广海报1</label>

                                                <div class="layui-input-inline">
                                                    <input type="text" name="tui1" value="{$site.tui1}"
                                                           placeholder="推广海报1" autocomplete="off" class="layui-input">
                                                </div>
                                                <button style="float: left;" type="button" class="layui-btn" id="test3">
                                                    上传海报
                                                </button>
                                            </div>
                                            <div class="layui-form-item">
                                                <label class="layui-form-label">推广海报2</label>

                                                <div class="layui-input-inline">
                                                    <input type="text" name="tui2" value="{$site.tui2}"
                                                           placeholder="推广海报2" autocomplete="off" class="layui-input">
                                                </div>
                                                <button style="float: left;" type="button" class="layui-btn" id="test4">
                                                    上传海报
                                                </button>
                                            </div>
                                            <div class="layui-form-item">
                                                <label class="layui-form-label">推广海报3</label>

                                                <div class="layui-input-inline">
                                                    <input type="text" name="tui3" value="{$site.tui3}"
                                                           placeholder="推广海报3" autocomplete="off" class="layui-input">
                                                </div>
                                                <button style="float: left;" type="button" class="layui-btn" id="test5">
                                                    上传海报
                                                </button>
                                            </div>
                                            <div class="layui-form-item">
                                                <label class="layui-form-label">昵称颜色</label>

                                                <div class="layui-input-inline" style="width: 120px;">
                                                    <input type="text" name="color" value="{$find.color}"
                                                           placeholder="请选择颜色" class="layui-input" id="test-form-input">
                                                </div>
                                                <div class="layui-inline" style="left: -11px;">
                                                    <div id="test-form"></div>
                                                </div>
                                            </div>
                                            <div class="layui-form-item">
                                                <div class="layui-input-block">
                                                    <button class="layui-btn" lay-submit lay-filter="set_website2">确认保存</button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-tab-item">
                                        <div class="layui-form" wid100 lay-filter="">
                                            <div class="layui-form-item">
                                                <label class="layui-form-label">佣金比例</label>

                                                <div class="layui-input-inline" style="width: 100px;">
                                                    <input type="number" name="ratio" lay-verify="required"
                                                           value="{$site.ratio}" placeholder="佣金比例" class="layui-input">
                                                </div>
                                                <div style="height: 38px;line-height: 38px;">%</div>
                                            </div>
                                            <div class="layui-form-item">
                                                <div class="layui-input-block">
                                                    <button class="layui-btn" lay-submit lay-filter="set_website3">确认保存</button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </fieldset>
        </div>
    </div>
</div>

<script src="/static/layuiadmin/layui/layui.js"></script>
<!-- 配置文件 -->
<script type="text/javascript" src="/static/ueditor/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="/static/ueditor/ueditor.all.js"></script>
<script type="text/javascript" src="/static/js/jquery-3.1.1.min.js"></script>
<script>
    layui.config({
        base: '/static/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'set', 'colorpicker'], function () {
        var $ = layui.jquery,
                upload = layui.upload,
                form = layui.form,
                colorpicker = layui.colorpicker;

        //表单赋值
        colorpicker.render({
            elem: '#test-form'
            , color: '#ffffff'
            , done: function (color) {
                $('#test-form-input').val(color);
            }
        });


        //编辑器
//        var huo = UE.getEditor('huo', {
//            initialFrameWidth: 800,
//            initialFrameHeight: 320
//        });
//        var yin = UE.getEditor('yin', {
//            initialFrameWidth: 800,
//            initialFrameHeight: 320
//        });

        //普通图片上传
        upload.render({
            elem: '#test'
            , url: "{:url('System/upload')}"
            , accept: 'file'
            , before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#demo').attr('src', result); //图片链接（base64）
                });
            }
            , done: function (res) {
                //如果上传失败
                if (res.code > 0) {
                    return layer.msg('上传失败');
                }
                //上传成功
                $("input[name=logo]").val(res.img);
                layer.msg("上传成功", {icon: 1});
            }
        });

        upload.render({
            elem: '#test2'
            , url: "{:url('System/upload')}"
            , accept: 'file'
            , before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#demo2').attr('src', result); //图片链接（base64）
                });
            }
            , done: function (res) {
                //如果上传失败
                if (res.code > 0) {
                    return layer.msg('上传失败');
                }
                //上传成功
                $("input[name=ad]").val(res.img);
                layer.msg("上传成功", {icon: 1});
            }
        });

        upload.render({
            elem: '#test3'
            , url: "{:url('System/upload')}"
            , accept: 'file'
            , done: function (res) {
                //如果上传失败
                if (res.code > 0) {
                    return layer.msg('上传失败');
                }
                //上传成功
                layer.msg('上传成功');
                $("input[name=tui1]").val(res.img);
            }
        });

        upload.render({
            elem: '#test4'
            , url: "{:url('System/upload')}"
            , accept: 'file'
            , done: function (res) {
                //如果上传失败
                if (res.code > 0) {
                    return layer.msg('上传失败');
                }
                //上传成功
                $("input[name=tui2]").val(res.img);
                layer.msg("上传成功", {icon: 1});
            }
        });

        upload.render({
            elem: '#test5'
            , url: "{:url('System/upload')}"
            , accept: 'file'
            , done: function (res) {
                //如果上传失败
                if (res.code > 0) {
                    return layer.msg('上传失败');
                }
                //上传成功
                $("input[name=tui3]").val(res.img);
                layer.msg("上传成功", {icon: 1});
            }
        });

        form.on('submit(set_website)', function (data) {
            var field = data.field;
//            field.huo = huo.getContent();
//            field.yin = yin.getContent();
            $.post("{:url('System/site')}", {field:field,type:1}, function (e) {
                if (e == 1) {
                    layer.msg('修改成功', {icon: 1});
                } else {
                    layer.msg('修改失败', {icon: 2});
                }
            })
        });

        form.on('submit(set_website2)', function (data) {
            var field = data.field;
//            field.huo = huo.getContent();
//            field.yin = yin.getContent();
            $.post("{:url('System/site')}", {field:field,type:2}, function (e) {
                if (e == 1) {
                    layer.msg('修改成功', {icon: 1});
                } else {
                    layer.msg('修改失败', {icon: 2});
                }
            })
        });

        form.on('submit(set_website3)', function (data) {
            var field = data.field;
//            field.huo = huo.getContent();
//            field.yin = yin.getContent();
            $.post("{:url('System/site')}", {field:field,type:3}, function (e) {
                if (e == 1) {
                    layer.msg('修改成功', {icon: 1});
                } else {
                    layer.msg('修改失败', {icon: 2});
                }
            })
        });

        form.on('submit(set_website4)', function (data) {
            var field = data.field;
//            field.huo = huo.getContent();
//            field.yin = yin.getContent();
            $.post("{:url('System/site')}", {field:field,type:4}, function (e) {
                if (e == 1) {
                    layer.msg('修改成功', {icon: 1});
                } else {
                    layer.msg('修改失败', {icon: 2});
                }
            })
        });

    });
</script>
</body>
</html>